import { createStore, applyMiddleware, combineReducers } from 'redux'
import thunk from 'redux-thunk'
import clientRequest from '../client/request'
import serverRequest from '../server/request'
import { reducer as homeReducer } from '../containers/Home/store'
import { reducer as headerReducer } from '../components/Header/store'


const reducer = combineReducers({
    home: homeReducer,
    head: headerReducer
});

export function getClientStore() {
    let defaultState = window._context.state;
    return createStore(reducer, defaultState, applyMiddleware(thunk.withExtraArgument(clientRequest)))
}

export function getServerStore(req) {
    return createStore(reducer, applyMiddleware(thunk.withExtraArgument(serverRequest(req))))
}

